<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ include file="/pages/jsp/internal/include.jsp" %>
 
<h3><fmt:message key="label.documentRelatedList"/></h3>

contentId :      <c:out value="${model.contentId}"/> <br>


<c:forEach items="${model.messages}" var="message">
	<div id="message"><fmt:message key="${message}"/></div>
</c:forEach>

<c:forEach items="${model.errors}" var="error">
	<div id="error">
		<fmt:message key="${error.key}">
			<fmt:param value="${error.param1}"/>
		</fmt:message>
	</div>
</c:forEach>

<!-- DOCUMENTI DA ASSOCIARE -->

<c:if test="${not empty model.files}">
	<form  id="manageDocumentForm" method="post">
		<input type="hidden" name="contentId" value="<c:out value="${model.contentId}"/>"/>
		
		<table id="tableRelateDocument" class="tablesorter">
			<thead>
				<tr>
					<th>&nbsp;</th>
			   		<th>Name</th>
			   		<th>Description</th>
					<th>Type</th>
			   	</tr>
	 		</thead>
			<c:forEach items="${model.files}" var="file" varStatus="i">
				<tr>
					<td><input type="checkbox" name="fileId" value="<c:out value="${file.id}"/>"></td>
			   		<td><c:out value="${file.name}"/></td>
					<td><c:out value="${file.description}"/></td>
					<td><c:out value="${file.type}"/></td>
			   	</tr>
			 </c:forEach>
		</table>
		
		<input type="button" value="Associa Documento" onclick="sendFormForAction('<c:url value="/content/manageRelationDocument.htm"/>','manageDocumentForm','hasDocDiv','createRelation');"/>
	</form>
</c:if>



<!-- DOCUMENTI ASSOCIATE -->

<c:if test="${not empty model.relatedFiles}">

	<fmt:message key="label.documentRelatedToContent"/>
	
	<form  id="manageDocumentRelatedForm" method="post">
		<input type="hidden" name="contentId" value="<c:out value="${model.contentId}"/>"/>
		<table id="tableRelatedDocumentToContent" class="tablesorter">
			<thead>
				<tr>
					<th>&nbsp;</th>
			   		<th>Name</th>
			   		<th>description</th>
					<th>type</th>
			   	</tr>
	 		</thead>
			<c:forEach items="${model.relatedFiles}" var="relatedFile" varStatus="i">
				<tr>
					<td><input type="checkbox" name="fileId" value="<c:out value="${relatedFile.id}"/>"></td>
			   		<td><c:out value="${relatedFile.name}"/></td>
					<td><c:out value="${relatedFile.description}"/></td>
					<td><c:out value="${relatedFile.type}"/></td>
			   	</tr>
			</c:forEach>
		</table>
		
		<input type="button" value="Elimina Associazione" onclick="sendFormForAction('<c:url value="/content/manageRelationDocument.htm"/>','manageDocumentRelatedForm','hasDocDiv','deleteRelation');"/>
	</form>
</c:if>


<script type="text/javascript" src="<c:url value="/js/table/jquery.tablesorter.js"/>"></script>
<script>
$(document).ready(function() { 
	$("#tableRelateImage").tablesorter();
	$("#tableRelatedImageToContent").tablesorter();
});

</script>
